package com.log320.huffman;

import java.util.ArrayList;
import java.util.LinkedList;
/**
 * Abstract class representing a node in the binary tree.
 *
 */
public abstract class BinaryComponent  implements Comparable{
    protected int frequency;
    protected int character;
    
    public BinaryComponent(int character, int frequecy){
    	this.character = character;
    	this.frequency = frequecy;
    }
    
    /**
     * Comparator by frequency
     */
	@Override
	public int compareTo(Object arg0) {
		if (arg0 == null)
			throw new NullPointerException();
		int result;
		if(frequency < ((BinaryComponent)arg0).frequency)
			result = -1;
		else if(frequency == ((BinaryComponent)arg0).frequency)
			result = 0;
		else
			result = 1;
		// TODO Auto-generated method stub
		return result;
	}
	public abstract int Decode(BitInputStream stream);
	public abstract void buildLeafArray(ArrayList<BinaryCode> bitArray,LinkedList<Boolean> tempBitArray);
}
